
demos.Patientslist = new Ext.List({
	onItemDisclosure: function(record) {

        var selectedPat = record;
        var newExam = new demos.Examcontrol;
        var ui = sink.Main.ui;
        var navBar = ui.navigationBar;
        var navBarTitle = selectedPat.data.name;
        
//        this.hide;   // <-- this works


// KR        if (Ext.is.Phone) demos.Maincontrol.tabBar.setVisible(false);

//        console.debug(cchpicard.items.items.length);
        
/*        while (cchpicard.items.items.length > 2) {
            console.debug(cchpicard.items.items.length);
            cchpicard.items.items.pop();
        };
        
//        console.debug(cchpicard.items.items.length);

        cchpicard.doComponentLayout();
        cchpicard.doLayout(); 
        
        newExam.doComponentLayout();
        newExam.doLayout(); */
        
        navBar.items.items.push(ui.addMxButton);
        navBar.items.items.push(ui.addHxButton);
        navBar.items.items.push(ui.saveButton);
        
//        newExam.tabBar.activeTab = newExam.tabBar.items[0];
        
        ui.setActiveItem(newExam, {type: 'slide', direction: 'left'});
        ui.currentCard = newExam;
        
        ui.addMxButton.hide();
        ui.addHxButton.show();
        ui.saveButton.show();
        
 //       console.debug('UI title = '+selectedPat.data.name);
        
        if (!Ext.is.Phone) navBarTitle += ' ('+selectedPat.data.id+')';

        navBar.titleEl.dom.innerText = navBarTitle;
        
 //       console.debug('UI title = '+selectedPat.data.id);

        navBar.title = selectedPat.data.id;

        ui.doComponentLayout();
        ui.doLayout();

        navBar.doComponentLayout();
        navBar.doLayout();
        
// KR        var patientbadge = patientscard.tab;
// KR        badgeNumber = parseInt(patientbadge.badgeText);
// KR        nextNumber = isNaN(badgeNumber) ? 1 : badgeNumber+1;
// KR        patientbadge.setBadge(nextNumber);

        
// -KR        newPat.id = selectedPat.data.id;
// -KR        newPat.title = selectedPat.data.id;

//            ToolbarDemo.views.viewport.setActiveItem(newPat);  --> KR removed temporarily
    },
    store: null,
    itemTpl:'<img valign=middle src="{url}" />&nbsp;&nbsp;&nbsp;{name}'
});
